//
//  accessTokenModel.swift
//  swift一遍敲
//
//  Created by 刘耀宗 on 16/4/19.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

import UIKit

class accessTokenModel: NSObject,NSCoding {
    
    
    
//    static let shareAccess = accessTokenModel()
    
    
    var access_token: String?
    var expires_in: NSTimeInterval = 0
    var remind_in: String?
    var uid: String?
    var screen_name: String?
    
    /// 用户头像地址（大图）180×180像素
    var avatar_large: String?
    
    /*
     /// 用户授权的唯一票据
     var access_token: String?
     
     /// access_token的生命周期，单位是秒数, 基本数据类型不要定义为可选,定义为可选,kvc找不到这个属性
     var expires_in: NSTimeInterval = 0 {
     didSet {
     // 当KVC给expires_in赋值完后,我们来创建expiresDate
     expiresDate = NSDate(timeIntervalSinceNow: expires_in)
     }
     }
     
     /// 过期时间 NSDate,NSDate比较时间方便
     var expiresDate: NSDate?
     
     /// 授权用户的UID
     var uid: String?
     
     /// 用户昵称
     var screen_name: String?
     
     /// 用户头像地址（大图）180×180像素
     var avatar_large: String?
     
     
     */
    //转模型
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
        
    }
    //忽略
    override func setValue(value: AnyObject?, forUndefinedKey key: String){
        
    }
    //归档
    func encodeWithCoder(aCoder: NSCoder) {
        aCoder.encodeObject(access_token, forKey: "access_token")
         aCoder.encodeObject(expires_in, forKey: "expires_in")
         aCoder.encodeObject(remind_in, forKey: "remind_in")
         aCoder.encodeObject(uid, forKey: "uid")
        
    }
    
    //解档
    required init?(coder aDecoder: NSCoder) {
       access_token = aDecoder.decodeObjectForKey("access_token") as? String
      expires_in = (aDecoder.decodeObjectForKey("expires_in") as? NSTimeInterval)!
      remind_in = aDecoder.decodeObjectForKey("remind_in") as? String
      uid = aDecoder.decodeObjectForKey("uid") as? String
        
    }
 
    
  //  var code: String?
    
//    var  parameters = [
//        "client_id": client_id,
//        "client_secret": client_secret,
//        "grant_type":"authorization_code",
//        "code": code
//    
//    
//    ]
//    
//   private  func loadAccessModel()
//    {
//       // HMAFNTool.shareAfnwork.POST(URL, parameters: <#T##AnyObject?#>, success: <#T##((NSURLSessionDataTask, AnyObject?) -> Void)?##((NSURLSessionDataTask, AnyObject?) -> Void)?##(NSURLSessionDataTask, AnyObject?) -> Void#>, failure: <#T##((NSURLSessionDataTask?, NSError) -> Void)?##((NSURLSessionDataTask?, NSError) -> Void)?##(NSURLSessionDataTask?, NSError) -> Void#>)
//    
//    }

}
